import logging

from redis import StrictRedis

class Config(object):
    DEBUG = True

    WTF_CSRF_ENABLED = True

    SECRET_KEY = "iECgbYWReMNxkRprrzMo5KAQYnb2UeZ3bwvReTSt+VSESW0OB8zbglT+6rEcDW9X"

    # 配置数据库
    SQLALCHEMY_DATABASE_URI = "mysql://foo:123@127.0.0.1:3306/test"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 配置redis
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 设置session
    SESSION_TYPE = 'redis'
    # 设置redis地址
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    # 设置session签名（严格加密）
    SESSION_USE_SIGNER = True
    # 取消session常驻
    SESSION_PERMANENT = False
    # 设置过期时间（2天）
    PERMANENT_SESSION_LIFETIME = 84600



class DevelopmentConfig(Config):
    """开发环境"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG

class ProductionConfig(Config):
    """生产环境"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING

class TestingConfig(Config):
    """单元测试环境下的配置"""
    DEBUG = True
    TESTING = True


config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}




